import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		hasLogin: false,
		watchTime: 0,
		userInfo: {},
		pushMessage: {},
		floatCall: null,
		weburl:"",
		codeResults: {}
	},
	mutations: {
		setWeburl(state,weburl){
			state.weburl = weburl
		},
		getWeburl(state){
			return state.weburl
		},
		updatePushMessage(state, message) {
			/**  
			 * 注意：这里为了方便预览查看效果，始终对 payload 做了序列化的处理。  
			 * 实际开发期中，请自行调整代码并注意发送的 payload 消息格式。  
			 */   
			let payload = message.payload;  
			if (typeof payload !== 'string') {  
				message.payload = JSON.stringify(payload);  
			}  
			state.pushMessage = message || {};
		},
		login(state) {
			state.hasLogin = true;
		},
		logout(state) {
			state.hasLogin = false;
		},
		setWatchTime(state, watchTime) {
			state.watchTime = watchTime;
		},
		updateCodeResults(state, codeResults) {
			state.codeResults = codeResults;  
		}
	},
	actions: {

	}
})

export default store
